import ProCard from '@ant-design/pro-card';
import { Typography, Divider, Empty, Tooltip, Space, Tag } from 'antd';
import { useRequest } from '@umijs/hooks';
import { getEnterprisesDetails } from '@/services/zhirong/enterprise';
import { useEffect, useState } from 'react';
import { QuestionCircleOutlined, IeCircleFilled, BulbFilled } from '@ant-design/icons';
import './companyInfo.module.css';
import { Avatar, Card, } from 'antd';
const { Meta } = Card;

const { Title } = Typography;

const CompanyInfo = ({ focusNodeId }) => {
  console.log('cname', focusNodeId)
  const [focusNodeInfo, setFocusNodeInfo] = useState({});
  const { run: runGetEnterprisesDetails, loading } = useRequest(getEnterprisesDetails, {
    manual: true,
    onSuccess: (result) => {
      if (result && result.code === 200) {
        setFocusNodeInfo({
          // 错误原因是这里之前写成了enterpriseList

          //basic: result.data.enterpriseDetail,
          basic: result.data[0],
        });
        console.log('success!---', focusNodeInfo.basic);
      }
    },
  });

  const clickTest = (value) => {
    sessionStorage.setItem('comName', focusNodeInfo.basic?.FullName)
    if (value.indexOf('EquityNetwork' != -1)) {
      sessionStorage.setItem('centerId', focusNodeInfo.basic?.eid || 'c97ca8d1-ae17-43e4-8bac-b4b22051484c')
      sessionStorage.setItem('comStatus', focusNodeInfo.basic?.Status)
    }
    if (value.indexOf('RiskDetection' != -1)) {
      sessionStorage.setItem('stockCode', '000001')
    }
    //window.location.href = value
    window.open(value)

  };
  useEffect(() => {
    if (focusNodeId) {
      runGetEnterprisesDetails({
        company_name: focusNodeId,

      });
    }
  }, [focusNodeId, runGetEnterprisesDetails]);

  return (
    <ProCard
      direction="column"
      style={{ height: '100%' }}
      loading={loading}
      bodyStyle={{ padding: 0 }}
    >
      <ProCard layout="center" className='headCard'>
        <Title level={4} >
          {focusNodeInfo.basic ? (
            <>
              <div style={{ marginBottom: '10px' }}>{focusNodeInfo.basic?.FullName || ''}
                <Space style={{ marginLeft: '3px' }}>
                  {String(focusNodeInfo.basic?.Status).indexOf('存续') !== -1 && <Tag color="blue">存续</Tag>}
                  {String(focusNodeInfo.basic?.Status).indexOf('注销') !== -1 && <Tag color="orange">注销</Tag>}
                  {String(focusNodeInfo.basic?.Status).indexOf('迁出') !== -1 && <Tag color="orange">迁出</Tag>}
                  {String(focusNodeInfo.basic?.Status).indexOf('吊销') !== -1 && <Tag color="red">吊销</Tag>}
                </Space>
              </div>


              <a className='headLink' href={'https://' + focusNodeInfo.basic?.Website || ''} target='_blank'>
                <IeCircleFilled
                  style={{
                    color: '#722ed1',
                    fontSize: '14px',
                    marginRight: '3px',
                  }}
                />{focusNodeInfo.basic?.Website || ''}</a>
              <p className='headAdress'>
                <BulbFilled
                  style={{
                    color: '#722ed1',
                    fontSize: '14px',
                    marginRight: '2px',
                  }}
                />

                {focusNodeInfo.basic?.OfficeAddress || ''}</p>
              {/* <Tooltip title="点击节点查看详细信息">
                <QuestionCircleOutlined
                  style={{
                    color: '#999999',
                    fontSize: '14px',
                    marginLeft: '2px',
                    marginBottom: '5px',
                  }}
                />
              </Tooltip> */}
              <div style={{
                marginTop: '20px', display: 'flex', justifyContent: 'flex-start', flexDirection: 'row',
              }}>



                <Card className='cardInfo' onClick={clickTest.bind(this, '/DataIntegration')}>
                  <Meta
                    avatar={<Avatar src="/news.png" className='cardInfoImg' />}
                    title="新闻热点"
                    description="新闻热点999+"
                  />
                </Card>


                <Card className='cardInfo' onClick={clickTest.bind(this, '/RiskDetection')}>
                  <Meta
                    avatar={<Avatar src="/fx.png" className='cardInfoImg' />}
                    title="风险发现"
                    description="风险发现999+"
                  />
                </Card>

                <Card className='cardInfo' onClick={clickTest.bind(this, '/RiskAnalysis/EquityNetwork')}>
                  <Meta
                    avatar={<Avatar src="/stock.png" className='cardInfoImg' />}
                    title="股权结构"
                    description="股权结构999+"
                  />
                </Card>

                {/* <div className={styles.linkBox}>新闻热点</div>
                <div className={styles.linkBox}>风险发现</div>
                <div className={styles.linkBox}>股权结构</div> */}
              </div>
              {/* <div style={{ marginTop: '20px', fontWeight: 'normal', fontSize: 'small' }}>
                包商银行股份有限公司（Baoshang Bank
                Limited，简称包商银行）于1998年12月28日经中国人民银行批准设立，前身为包头市商业银行，2007年9月28日经中国银监会批准更名为包商银行，成为区域性股份制商业银行，总部设在包头市。
              </div> */}
            </>
          ) : (
            '点击节点查看详细信息'
          )}
        </Title>
      </ProCard>
      <Divider />
      <ProCard direction="column" className='proCard'>
        <div className='labelDiv'>

          <span> 工商信息</span>


        </div>
        {focusNodeInfo.basic ? (
          <>

            <p>
              <b style={{ fontSize: '15px' }}>法定代表人：</b>
              {focusNodeInfo.basic?.LegalRepresentative || ''}
            </p>
            <p>
              <b style={{ fontSize: '15px' }}>成立时间：</b>
              {focusNodeInfo.basic?.EstablishDate || ''}
            </p>
            <p>
              <b style={{ fontSize: '15px' }}>经营状态：</b>
              {focusNodeInfo.basic?.Status || ''}
            </p>
            <p>
              <b style={{ fontSize: '15px' }}>注册资本：</b>
              {focusNodeInfo.basic?.RegisterCapital || ''}
              {/* {Number(focusNodeInfo.basic?.RegisterCapital / 10000).toFixed(2) + ' 万元' || ''} */}
            </p>
            {/* <p>
              <b style={{ fontSize: '15px' }}>工商注册号：</b>
              {focusNodeInfo.basic?.regId || ''}
            </p> */}
            <p>
              <b style={{ fontSize: '15px' }}>社会统一信用代码：</b>
              {focusNodeInfo.basic?.SocialCreditCode || ''}
            </p>
            <p>
              <b style={{ fontSize: '15px' }}>经营范围：</b>
              {focusNodeInfo.basic?.BusinessScope || ''}
            </p>
            <p>
              <b style={{ fontSize: '15px' }}>联系电话：</b>
              {focusNodeInfo.basic?.SecretaryTel || ''}
            </p>
          </>
        ) : (
          <Empty></Empty>
        )}
      </ProCard>
    </ProCard>
  );
};

export default CompanyInfo;
